#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "GLDisplay.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->actionWireFrame, SIGNAL(toggled(bool)), this, SIGNAL(wireframeClicked(bool)));
    connect(ui->actionLight_Rotation, SIGNAL(toggled(bool)), this, SIGNAL(lightRotationToggle(bool)));
    connect(ui->actionSaveImageAs, SIGNAL(triggered()), this, SIGNAL(saveResultAsImage()));
    connect(ui->ckbOrigin, SIGNAL(toggled(bool)), this, SIGNAL(origin(bool)));

    connect(ui->goBT, SIGNAL(clicked()), this, SLOT(go()));
    connect(ui->editExpresion, SIGNAL(returnPressed()), this, SLOT(go()));
    connect(ui->stacks, SIGNAL(editingFinished()), this, SLOT(go()));
    connect(ui->slices, SIGNAL(editingFinished()), this, SLOT(go()));
    connect(ui->xRange, SIGNAL(editingFinished()), this, SLOT(go()));
    connect(ui->yRange, SIGNAL(editingFinished()), this, SLOT(go()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::setGLDisplay(GLDisplay *display)
{
    ui->verticalLayout->addWidget(display);
}

void MainWindow::go()
{
    emit parameters(ui->stacks->value(), ui->slices->value(),
                    ui->xRange->value(), ui->yRange->value(),
                    ui->editExpresion->text());
}
